package com.helmlabs.grouper.core.security;

import junit.framework.TestCase;

import org.springframework.security.GrantedAuthority;
import org.springframework.security.GrantedAuthorityImpl;
import org.springframework.security.context.SecurityContext;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.security.context.SecurityContextImpl;
import org.springframework.security.providers.UsernamePasswordAuthenticationToken;

public class BaseSecurityTestCase extends TestCase {
	
	private SecurityContext initialSecurityContext = null;
	
	protected void setUp() throws Exception {
		super.setUp();
        initialSecurityContext = SecurityContextHolder.getContext();
        
        SecurityContext context = new SecurityContextImpl();
        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("user",
                "password",
                new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_USER")});
        context.setAuthentication(token);
        SecurityContextHolder.setContext(context);
	}

}
